Skip to content

ops: smoother update and deploy workflows#37

Merged
benvinegar merged 2 commits into
mainfrom
benvinegar/smoother-ops
Feb 17, 2026
Merged

ops: smoother update and deploy workflows#37
benvinegar merged 2 commits into
mainfrom
benvinegar/smoother-ops

Conversation

@benvinegar
Copy link
Copy Markdown
Member

Problem

Updating baudbot required three separate commands:

cd ~/hornet && git pull origin main
sudo BAUDBOT_CONFIG_USER=bentlegen ~/hornet/bin/deploy.sh
sudo baudbot start

Fix

baudbot update does everything

sudo baudbot update

Pulls latest, deploys, and restarts if running. One command.

baudbot deploy auto-detects admin user

No more BAUDBOT_CONFIG_USER=bentlegen. Deploy now detects the admin from the repo's file ownership (stat -c '%U') when SUDO_USER isn't available. So sudo baudbot deploy just works.

- baudbot update now pulls, deploys, and restarts in one command
  (was: pull + deploy only, user had to restart manually)
- deploy.sh auto-detects admin user from repo ownership when
  SUDO_USER isn't set, so 'sudo baudbot deploy' just works
  without needing BAUDBOT_CONFIG_USER env var
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 17, 2026

Greptile Summary

This PR simplifies the baudbot update workflow from three manual commands into a single sudo baudbot update, and improves admin user auto-detection in deploy.sh so BAUDBOT_CONFIG_USER no longer needs to be set manually.

  • bin/baudbotupdate command: The previous exec deploy.sh (which replaced the process entirely) is correctly dropped so that post-deploy restart logic can execute. The new block pulls from git, runs deploy, then conditionally restarts the systemd unit and checks liveness with a sleep 2 poll.
  • bin/deploy.sh — admin user detection: The single-expression fallback ${BAUDBOT_CONFIG_USER:-${SUDO_USER:-$(whoami)}} is replaced with an explicit priority chain that now correctly excludes SUDO_USER=root (e.g. nested sudo sessions) and adds a new stat -c '%U' repo-ownership heuristic as the third-priority fallback. The BAUDBOT_CONFIG_USER env-var path used by install.sh is unaffected.
  • Minor style issues: &>/dev/null 2>&1 is redundant (lines 266, 270 of bin/baudbot); the hard-coded sleep 2 before the liveness re-check may produce false warnings on slower systems; and SUDO_USER quoting is inconsistent in the new elif guard.

Confidence Score: 4/5

  • Safe to merge — changes are additive ops tooling with no impact on agent security boundaries.
  • Both changes are straightforward operational improvements. The drop of exec in the update command is intentionally correct. The deploy user detection chain is a strict improvement over the prior one-liner, and the BAUDBOT_CONFIG_USER override used by install.sh remains the highest-priority path. No security-critical files or agent runtime logic is touched. Minor style issues (redundant redirections, hard-coded sleep) lower the score slightly.
  • No files require special attention — all changes are in ops tooling only.

Important Files Changed

Filename Overview
bin/baudbot The update command is extended to run deploy then conditionally restart systemd. The key change drops exec (correct, since more work follows). New &>/dev/null 2>&1 redirections are redundant but harmless; sleep 2 is a hard-coded polling delay which may be fragile on slow systems.
bin/deploy.sh Admin user detection is improved with a fallback chain: env var > SUDO_USER (explicitly excluding "root") > stat -c '%U' repo owner > whoami. The SUDO_USER != "root" guard is a good addition. The stat -c '%U' call is Linux-only (GNU stat), consistent with the project's Linux-only target. Overall logic is sound.

Sequence Diagram

sequenceDiagram
    actor Admin
    participant baudbot as baudbot (CLI)
    participant git as git
    participant deploy as deploy.sh
    participant systemd as systemd

    Admin->>baudbot: sudo baudbot update
    baudbot->>baudbot: require_root()
    baudbot->>git: git pull origin main
    git-->>baudbot: latest code
    baudbot->>deploy: deploy.sh [args]
    Note over deploy: detect DEPLOY_USER:<br/>1. BAUDBOT_CONFIG_USER env<br/>2. SUDO_USER (if not root)<br/>3. stat -c '%U' repo owner<br/>4. whoami
    deploy-->>baudbot: exit 0
    baudbot->>systemd: systemctl is-active baudbot
    alt service is running
        baudbot->>systemd: systemctl restart baudbot
        baudbot->>baudbot: sleep 2
        baudbot->>systemd: systemctl is-active baudbot
        alt still active
            baudbot-->>Admin: ✅ Updated and running
        else crashed
            baudbot-->>Admin: ⚠️ Deployed but agent didn't restart
        end
    else service not running
        baudbot-->>Admin: ✅ Updated. Start with: sudo baudbot start
    end
Loading

Last reviewed commit: 37ef17d

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment thread bin/baudbot Outdated
Comment thread bin/baudbot Outdated
Comment thread bin/deploy.sh Outdated
- Remove redundant 2>&1 after &>/dev/null (4 instances in baudbot)
- Consistent ${SUDO_USER:-} quoting in deploy.sh
- Bump restart wait to 3s with comment explaining why
@benvinegar benvinegar merged commit c1aeeac into main Feb 17, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant